package com.bolt.report.engine.calculator;

import com.bolt.report.engine.BindData;
import com.bolt.report.engine.Calculator;
import com.bolt.report.engine.fill.FillContext;
import com.bolt.report.engine.model.Cell;
import com.bolt.report.engine.model.Expression.CalculatorExpression;

import java.text.DecimalFormat;

public class PercentCalculator implements Calculator {
    @Override
    public Object evaluate(FillContext context, BindData data, CalculatorExpression expr, Cell cell) {
        if ((!data.isMultiple())) {
            Object value = data.getData();
            DecimalFormat df = new DecimalFormat("#.##%");
            return df.format(value);
        }
        return data.getData();
    }



}